home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ Jul 89 / W0078-putPicProc Abnormal-Jul89 < prev    next >
Encoding:
Text File  |  1989-07-18  |  3.4 KB  |  115 lines  |  [TEXT/GEOL]

  1. Item    0791527                         17-July-89        10:24
  2.  
  3. From:   D3904                           The Complete PC, PRT
  4.  
  5. To:     MACDTS                          Macintosh Developer Technical Supt.
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.  
  9. Sub:    putPicProc Abnormalities
  10.  
  11. 7/17/89
  12.  
  13. To:  MacDTS
  14.  
  15. From: Ann Huang
  16.  
  17. cc:  MACAPP.TECH$
  18.  
  19. With MacApp 2.0b5,  we are try to spool a picture to a file in a very similar
  20. fashion to the example in Inside Macintosh Vol. 5, pgs. 89-90.   The problem is
  21. that the example is not very clear.   In other words,  we can't get it to work.
  22.  
  23. The example uses DrawPicture and we want to use CopyBits to convert our
  24. internal scanned-in bitmap to PICT format.   This seems to be causing us some
  25. problems.   Our new putPicProc procedure never gets called with the right
  26. parameters.   And,  strangely enough the default procedure never seems to be
  27. called at all with CopyBits (when we do not overwrite the bottleneck).
  28.  
  29. The reason we want to do this is two-fold,  one,  we want to know the size of
  30. the bitmap as a PICT for our DoNeedDiskSpace routine;  and two,  we want to
  31. write our bitmap to disk as a PICT.   Currently,  we are just making a
  32. duplicate in memory with CopyBits and then writing to disk (a rather gross
  33. misuse of memory).
  34.  
  35. Here is our code (please flame us):
  36. {-----------------------------------+
  37.     |    ConvertToPICT                                          |
  38.     +-----------------------------------}
  39.     FUNCTION ConvertToPICT:LONGINT;
  40.     CONST
  41.             DrawBegin    =    130;
  42.             DrawEnd        =    131;
  43.             BitBegin    =    142;
  44.             BitEnd        =    143;
  45.  
  46.     VAR
  47.             frameRect,
  48.             pictRect:    Rect;
  49.             tempPort:    GrafPort;
  50.             aPicture:    PicHandle;
  51.             aBitMap:    BitMap;
  52.             totalCount:    LONGINT;
  53.             myProcs:    QDProcs;
  54.             savedProcs:    QDProcsPtr;
  55.         
  56.        {----------------------------------------------------+
  57.        |        PutPICTData: find out the size of the picture   |
  58.        +----------------------------------------------------}
  59.         
  60.         PROCEDURE PutPICTData(dataPtr: Ptr; byteCount: INTEGER);
  61.             VAR
  62.                     longCount :    LONGINT;
  63.                     err    :        OSErr;
  64.             BEGIN
  65.                     longCount := LONGINT(byteCount);
  66.                     totalCount := totalCount + longCount;
  67.             END;
  68.         
  69.     BEGIN
  70.             {create the picture}
  71.             OpenPort(@tempPort);
  72.             aBitMap := fScanBitMap;
  73.             SetPortBits(aBitMap);
  74.             fScanView.GetQDExtent(pictRect);
  75.             SetPort(@tempPort);
  76.             ScaleRect(pictRect,frameRect,dpi(fImageResolution),dpi(fSaveResolution));
  77.  
  78.             totalCount := LONGINT(0);
  79.         
  80.             SetStdProcs(myProcs);  { re-route to our procedure }
  81.             myProcs.putPicProc := @PutPICTData;
  82.             savedProcs := thePort^.grafProcs;
  83.             thePort^.grafProcs := @myProcs;
  84.         
  85.             aPicture := OpenPicture(frameRect);
  86.             PicComment(DrawBegin,0,NIL);
  87.             PicComment(BitBegin,0,NIL);
  88.             ClipRect(pictRect);
  89.             CopyBits(aBitMap,aBitMap,pictRect,frameRect,srcCopy,NIL);
  90.             PicComment(BitEnd,0,NIL);
  91.             PicComment(DrawEnd,0,NIL);
  92.             ClosePicture;
  93.             thePort^.grafProcs := savedProcs;    
  94.  
  95.             ClosePort(@tempPort);
  96.         
  97.             {check if picture creation failed}
  98.             IF EmptyRect(aPicture^^.picFrame) THEN
  99.             BEGIN
  100.                     KillPicture(aPicture);
  101.                     Failure(memFullErr, 0);
  102.             END;
  103.             gPicture := Handle(aPicture);
  104.             ConvertToPICT := GetHandleSize(gPicture)
  105.     END;
  106.  
  107. This question is MacApp related to the extent that we are hoping there is a
  108. MacApp procedure we are overlooking that will help us achieve a similar result.
  109.  
  110. Thanks in advance.
  111.  
  112. Ann
  113.  
  114.  
  115.